package com.atguigu.eduservice.controller;


import com.atguigu.commonutils.R;
import com.atguigu.eduservice.entity.EduComment;
import com.atguigu.eduservice.service.EduCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 评论 前端控制器
 * </p>
 *
 * @author huangqicai
 * @since 2023-03-30
 */
@Api(value = "评论功能")
@RestController
@RequestMapping("/eduservice/comment")
//原来需要在Controller上面加上@CrossOrigin解决跨域问题，现在gateway已经处理了
public class EduCommentController {

    @Autowired
    private EduCommentService commentService;


    @ApiOperation(value = "新增评论")
    @PostMapping("/auth/save")
    public R addComment(@RequestBody EduComment eduComment, HttpServletRequest request){
        return commentService.addComment(eduComment,request);
    }

    @ApiOperation(value = "根据课程id分页查询评论")
    @GetMapping("/getPageList/{current}/{limit}")
    public R getPageList(@PathVariable(value = "current") long current,
                         @PathVariable(value = "limit") long limit,
                         @RequestParam(value = "courseId") String courseId){
        return commentService.getPageList(current,limit,courseId);
    }

}

